<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>

    <title>欢迎来到Alone在线购书商城</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!-- 如果出现没有效果的情况直接检查是否是因为路径的问题 -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/easyui/themes/default/easyui.css"
          type="text/css"></link>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/easyui/themes/icon.css" type="text/css"></link>
    <script type="text/javascript" src="${pageContext.request.contextPath}/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/easyui/jquery.easyui.min.js"></script>
    <style type="text/css">
        a {
            text-decoration: none;
        }
    </style>

    <script type="text/javascript">
        function reinitIframe() {
            var iframe = document.getElementById("_content");
            try {
                var bHeight = iframe.contentWindow.document.body.scrollHeight;
                var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
                var height = Math.max(bHeight, dHeight);
                iframe.height = height;
            } catch (ex) {
            }
        }

        window.setInterval("reinitIframe()", 200);
    </script>

</head>

<body>
<body class="easyui-layout">

<div data-options="region:'north',title:'欢迎您来到Alone在线购书商城',split:true,iconCls:'icon-search'" style="height:100px;">
    <%--引入通用的头部页面 --%>
    <%@include file="/jsp/front/common/header.jsp" %>
</div>
<div data-options="region:'south',title:'版权信息',split:true" style="height:100px;text-align:center;">
    <br/>
    (C) Copyright 2019 yuanfeng All rights Reserved

</div>
<div data-options="region:'west',title:'图书分类',split:true" style="width:128px;">

    <br/>
    <a target="_content" href="<c:url value='/index?action=queryBooks'/>" class="easyui-linkbutton"
       data-options="iconCls:'icon-search'">
        全部
    </a>
    <br/>
    <br/>
    <c:forEach items="${requestScope.types}" var="type">
        <a class="easyui-linkbutton" data-options="iconCls:'icon-search'" target="_content"
           href="<c:url value='/index?action=queryBooks&typeId=${type.id}'/>">
                ${type.name}
        </a>
        <br/>
        <br/>
    </c:forEach>

</div>

<div data-options="region:'center',title:'书籍模块信息如下'" style="padding:5px;background:#CAE1FF;">

    <c:if test="${!empty sessionScope.user}">
        <script type="text/javascript">
            $.messager.alert('登陆', '登陆成功', 'info', function () {

            });

        </script>

    </c:if>
    <c:if test="${msg == '验证码错误'}">
        <script type="text/javascript">
            $.messager.alert('警告', '验证码错误', 'error', function () {
            });

        </script>
    </c:if>

    <c:if test="${msg == '用户名不存在'}">
        <script type="text/javascript">
            $.messager.alert('警告', '用户名不存在', 'error', function () {
            });
        </script>
    </c:if>

    <c:if test="${msg == '密码输入有误'}">

        <script type="text/javascript">
            $.messager.alert('警告', '密码输入有误', 'error', function () {
            });
        </script>
    </c:if>
    <c:if test="${result == 'failed'}">

        <script type="text/javascript">
            $.messager.alert('查询', '图书查询为空', 'warning', function () {
            });
        </script>
    </c:if>


    <form action="${pageContext.request.contextPath}/search?action=query" method="post">

        <select id="cc" class="easyui-combobox" name="dept" style="width:200px;">
            <option value="name">书名</option>
            <option value="auth">作者</option>
        </select>

        <input type="submit" value="查询" style="float:right;margin-left:5px;background:#BFEFFF;
			  "/>
        　 <input id="bookName" class="easyui-validatebox" type="text" name="bookName" style="float:right;"/>

    </form>
    <c:choose>
        <%--设置是否显示选择的当前图书--%>
        <c:when test="${!empty sessionScope.currentBook}">
            <c:set var="url"
                   value="${pageContext.request.contextPath}/index?action=queryBook&id=${sessionScope.currentBook}"></c:set>
            <c:remove var="currentBook" scope="session"/>
        </c:when>
        <c:otherwise>
            <c:set var="url" value="${pageContext.request.contextPath}/index?action=queryBooks"></c:set>
        </c:otherwise>
    </c:choose>
    <iframe id="_content" scrolling="no" name="_content"
            src="${pageContext.request.contextPath}/index?action=queryBooks" frameborder="0" width="800px"
            height="100%">
    </iframe>
</div>
</body>

<script type="text/javascript">

    var bookName;//图书名称
    bookName = textdocument.getElementById("search").value;
    alert(bookName);

    function searchBook() {
        window.location.href = "${pageContext.request.contextPath}/search?action=query&bookName=" + bookName;
    }
</script>
</html>
